/**
 * Project Name:renshuaipeng-parent
 * File Name:GreetingController
 * Package Name:ren.renshuaipeng.rest.web
 * Date:15-12-12
 * Copyright (c) 2015, niao.shuai123@163.com All Rights Reserved.
 */

package ren.renshuaipeng.util.rest.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ren.renshuaipeng.util.rest.domain.Greeting;

import java.util.concurrent.atomic.AtomicLong;

/**
 * ClassName:GreetingController <br/>  
 * Function: 欢迎. <br/>
 * Date:     15-12-12 <br/>  
 * @author 任帅鹏（作者）
 * @version V1.00 （版本号）  
 * @since JDK 1.8  
 * @see
 */
@RestController
public class GreetingController {
    private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

    @RequestMapping("/greeting")
    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
        return new Greeting(counter.incrementAndGet(),
                String.format(template, name));
    }
}
